<?php

namespace App\Admin\Actions\Post;

use Encore\Admin\Actions\BatchAction;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Http\Request;

class BatchISBN extends BatchAction {
	public $name = '批量ISBN';

	public function handle(Collection $collection, Request $request) {
		$isbn = $request->get('isbn');
		foreach ($collection as $model) {

			$model->isbn = $isbn;
			$model->save();
		}

		return $this->response()->success('修改成功')->refresh();
	}

	public function form() {
		$this->text('isbn', 'ISBN')->rules('required');
	}

}